{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b486396a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 占位符\n",
    "# * 优化字符串拼接:占位符%s 动态数据-->变量\n",
    "# - 优势：1.全部写在一个大的字符串里\n",
    "#      2.省略了+号\n",
    "# - 缺点 如果有很多个需要填进去的内容，容易顺序乱掉，出现问题*\n",
    "name = input('name:')\n",
    "age = int(input('age:'))\n",
    "job = input('job:')\n",
    "salary = int(input('salary:'))\n",
    "# %d=number %s=str\n",
    "info_占位符 = '''------INFO %s------\n",
    "name:%s\n",
    "age:%d\n",
    "job:%s\n",
    "salary:%d''' % (name, name, age, job, salary)\n",
    "print(info_占位符)\n",
    "\n",
    "# .format()格式化 字符串\n",
    "info_format = '''----INFO{姓名}----\n",
    "name:{姓名}\n",
    "age:{年龄}\n",
    "job：{工作}\n",
    "salary:{薪水}'''.format(年龄=age, 姓名=name, 工作=job, 薪水=salary)\n",
    "print(info_format)\n",
    "\n",
    "# .format()案例\n",
    "url = \"https://www.nfu.edu.cn/\"  # 官网的域名\n",
    "# 目标获取高教动态的所有url链接\n",
    "高教动态 = \"gjdt\"\n",
    "url_页面 = \".htm\"\n",
    "url_页面细节不变 = \"/index\"\n",
    "\n",
    "# for i in range(1,27):\n",
    "# 完整的高教动态所有页面url = url+高教动态+ url_页面细节不变 + str(i)+url_页面\n",
    "# print(完整的高教动态所有页面url)\n",
    "\n",
    "ztb = input('你想要打的广告内容：')\n",
    "for i in range(1, 27):\n",
    "    完整的高教动态所有页面url = \"https://www.nfu.edu.cn/{新闻}/index{页码}.htm\".format(页码=str(i), 新闻=ztb)\n",
    "    print(完整的高教动态所有页面url)\n",
    "\n",
    "# .format()尝试\n",
    "fl = ['stand_alone', 'esports', 'mobile', 'online', 'board']\n",
    "sq = ['2#', '3#', '4#', '5#', '6#']\n",
    "Url = 'https://www.bilibili.com/'  # b站域名\n",
    "# 获取游戏区域所有url链接\n",
    "游戏区 = 'v/game'\n",
    "url = '/'\n",
    "url_页面细节不变 = \"/?spm_id_from=333.6.b_7375626e6176.\"\n",
    "for i in fl:\n",
    "    for k in sq:\n",
    "        完整的游戏区所有页面url = 'https://www.bilibili.com/v/game/{分类}/?spm_id_from=333.6.b_7375626e6176.{书签}/'.format(分类=str(i),\n",
    "                                                                                                              书签=str(k))\n",
    "        print(完整的游戏区所有页面url)\n",
    "\n",
    "'''列表:包括课堂笔记及自学内容'''\n",
    "lst = ['hello', 'world', 98]\n",
    "'''创建列表的第二种方式，使用内置List（）'''\n",
    "lst2 = list(['hello', 'world', 98])\n",
    "print(id(lst))\n",
    "print(lst[0])\n",
    "\n",
    "'''列表的特点\n",
    "1.列表元素按顺序排序\n",
    "2.索引映射唯一数据\n",
    "3.列表可以存储重复数据\n",
    "4.任意数据混存\n",
    "5.根据动态分配回收内存'''\n",
    "\n",
    "# 获取 list的索引\n",
    "print(lst.index('hello'))  # 如果列表中有相同元素只返回列表中相同元素中的第一个，如果列表中无元素将会报错\n",
    "print(lst.index('hello', 0, 3))  # 在零到二中查找索引\n",
    "\n",
    "'''获取列表的多个元素--切片 slice，最右边的值是取不到的'''\n",
    "'''如果取值为空，说明slice写错了，如果从右往左取想要取到最后一个值，直接省略不写\n",
    "如果想要将整个列表取出，可以使用[:]，也可以使用for in遍历'''\n",
    "\n",
    "# 列表名[start:stop:step]\n",
    "lst3 = [10, 20, 30, 40, 50, 60, 70, 80]\n",
    "print(lst3[-3:])\n",
    "print(lst3[1:6:2])  # 切出来的列表是新的列表对象，他会对切出来的对象进行拷贝\n",
    "# ****重要 ****\n",
    "print(lst3[:])\n",
    "\n",
    "print('----步长为负数的情况----')\n",
    "print(lst3[::-1])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6fba876b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
